package com.wbc.demo.SingleCaseDemo;

/**
 * @author wangbingchen
 * @DATE: 2022/9/14
 * 这是一个饿汉式单例
 */

public class SingleCaseDemo {

    //静态不可变
    private static final SingleCaseDemo INSTANCE = new SingleCaseDemo();

    //私有化构造防止外部 new 加上判断 防止反射 强单例
    private SingleCaseDemo(){
        if(INSTANCE != null){
            throw new IllegalStateException();
        }
    }

    //唯一对外提供接口
    public static SingleCaseDemo getInstance(){
        return INSTANCE;
    }
}
